package com.diankangwo.util;

import java.util.UUID;
import java.util.concurrent.locks.ReentrantLock;

/**
 *  GUID生成
 * @author xiaoyu
 *
 */
public class GuidUtil {

	//声明重入锁
	static ReentrantLock lock = new ReentrantLock();

	public static String getGuid(){
		try{
			lock.lock();
			UUID uuid = UUID.randomUUID();
			String a = uuid.toString();
			a = a.toUpperCase();
			a = a.replaceAll("-", "");
			return a;
		}catch (Exception e){
			e.printStackTrace();
			return null;
		}finally {
			lock.unlock();
		}
	}
	
	public static void main(String[] args) {
		System.out.println(getGuid());
	}
	
}
